package com.web.dao;

import com.github.pagehelper.Page;
import com.web.controller.web.WebOrderController;
import com.web.entity.Order;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author FDjavaone
 */
public interface OrderMapper {


    @Delete({
            "delete from t_order ",
            " where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
            "insert into t_order (m_id, order_num,",
            " store_id,order_type,express_name, express_number,",
            " name, phone, address, ",
            " total_price, tip_price,transfer_price, ",
            " status,pay_type, create_time, ",
            " modify_time) ",
            " values (#{mId,jdbcType=BIGINT}, #{orderNum,jdbcType=VARCHAR}, ",
            " #{storeId,jdbcType=BIGINT},#{orderType,jdbcType=VARCHAR},#{expressName,jdbcType=VARCHAR}, #{expressNumber,jdbcType=VARCHAR}, ",
            " #{name,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, ",
            " #{totalPrice,jdbcType=DECIMAL}, #{tipPrice,jdbcType=DECIMAL}, #{transferPrice,jdbcType=DECIMAL}, ",
            " #{status,jdbcType=INTEGER},#{payType,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
            " #{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Long.class)
    int insert(Order record);

    @InsertProvider(type = OrderSqlProvider.class, method = "insertSelective")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Long.class)
    int insertSelective(Order record);


    @Select({
            "select",
            " id, m_id, order_num,store_id,order_type, express_name, express_number, name, phone, address, total_price, ",
            " tip_price,transfer_price, status,pay_type, create_time, modify_time ",
            " from t_order",
            " where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "m_id", property = "mId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_num", property = "orderNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "store_id", property = "storeId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_type", property = "orderType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_name", property = "expressName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_number", property = "expressNumber", jdbcType = JdbcType.VARCHAR),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "total_price", property = "totalPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "tip_price", property = "tipPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "transfer_price", property = "transferPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "pay_type", property = "payType", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP)
    })
    Order selectByPrimaryKey(Long id);


    @UpdateProvider(type = OrderSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Order record);

    @Update({
            "update t_order",
            " set m_id = #{mId,jdbcType=BIGINT},",
            " order_num = #{orderNum,jdbcType=VARCHAR},",
            " store_id = #{storeId,jdbcType=BIGINT},",
            " order_type = #{orderType,jdbcType=VARCHAR},",
            " express_name = #{expressName,jdbcType=VARCHAR},",
            " express_number = #{expressNumber,jdbcType=VARCHAR},",
            " name = #{name,jdbcType=VARCHAR},",
            " phone = #{phone,jdbcType=VARCHAR},",
            " address = #{address,jdbcType=VARCHAR},",
            " total_price = #{totalPrice,jdbcType=DECIMAL},",
            " tip_price = #{tipPrice,jdbcType=DECIMAL},",
            " transfer_price = #{transferPrice,jdbcType=DECIMAL},",
            " status = #{status,jdbcType=INTEGER},",
            " pay_type = #{payType,jdbcType=INTEGER},",
            " create_time = #{createTime,jdbcType=TIMESTAMP},",
            " modify_time = #{modifyTime,jdbcType=TIMESTAMP} ",
            " where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Order record);

    @SelectProvider(type = OrderSqlProvider.class, method = "selectByOrder")
    List<Order> selectByOrder(Order order);

    @Select({
            "select",
            " id, m_id, order_num,store_id,order_type, express_name, express_number, name, phone, address, total_price, ",
            " tip_price,transfer_price, status,pay_type, create_time, modify_time ",
            " from t_order ",
            " where m_id = #{mId,jdbcType=BIGINT} and status!='3' and status!='9' order by create_time desc"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "m_id", property = "mId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_num", property = "orderNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "store_id", property = "storeId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_type", property = "orderType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_name", property = "expressName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_number", property = "expressNumber", jdbcType = JdbcType.VARCHAR),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "total_price", property = "totalPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "tip_price", property = "tipPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "transfer_price", property = "transferPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "pay_type", property = "payType", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP)
    })
    List<Order> selectUnfinishOrder(Order order);

    @Select({
            "select",
            " id, m_id, order_num,store_id,order_type, express_name, express_number, name, phone, address, total_price, ",
            " tip_price,transfer_price, status,pay_type, create_time, modify_time ",
            " from t_order ",
            " where store_id = #{storeId,jdbcType=BIGINT} and status!='3'  and status!='9' order by create_time desc"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "m_id", property = "mId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_num", property = "orderNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "store_id", property = "storeId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_type", property = "orderType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_name", property = "expressName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_number", property = "expressNumber", jdbcType = JdbcType.VARCHAR),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "total_price", property = "totalPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "tip_price", property = "tipPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "transfer_price", property = "transferPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "pay_type", property = "payType", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP)
    })
    List<Order> selectUnfinishOrderByStore(Order order);


    @Select({
            "select",
            " id, m_id, order_num,store_id,order_type, express_name, express_number, name, phone, address, total_price, ",
            " tip_price,transfer_price, status,pay_type, create_time, modify_time ",
            " from t_order ",
            " where m_id = #{mId,jdbcType=BIGINT} and status='3' order by create_time desc"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "m_id", property = "mId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_num", property = "orderNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "store_id", property = "storeId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_type", property = "orderType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_name", property = "expressName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_number", property = "expressNumber", jdbcType = JdbcType.VARCHAR),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "total_price", property = "totalPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "tip_price", property = "tipPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "transfer_price", property = "transferPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "pay_type", property = "payType", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP)
    })
    List<Order> selectFinishOrder(Order order);

    @Select({
            "select",
            " id, m_id, order_num,store_id,order_type, express_name, express_number, name, phone, address, total_price, ",
            " tip_price,transfer_price, status,pay_type, create_time, modify_time ",
            " from t_order ",
            " where store_id = #{storeId,jdbcType=BIGINT} and status='3' order by create_time desc"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "m_id", property = "mId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_num", property = "orderNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "store_id", property = "storeId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_type", property = "orderType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_name", property = "expressName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_number", property = "expressNumber", jdbcType = JdbcType.VARCHAR),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "total_price", property = "totalPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "tip_price", property = "tipPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "transfer_price", property = "transferPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "pay_type", property = "payType", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP)
    })
    List<Order> selectFinishOrderByStoreId(Order order);

    @Select({
            "select",
            " id, m_id, order_num,store_id,order_type, express_name, express_number, name, phone, address, total_price, ",
            " tip_price,transfer_price, status,pay_type, create_time, modify_time ",
            " from t_order ",
            " where store_id = #{aLong,jdbcType=BIGINT} and status!='9' and create_time >= #{time,jdbcType=TIMESTAMP}"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "m_id", property = "mId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_num", property = "orderNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "store_id", property = "storeId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_type", property = "orderType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_name", property = "expressName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_number", property = "expressNumber", jdbcType = JdbcType.VARCHAR),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "total_price", property = "totalPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "tip_price", property = "tipPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "transfer_price", property = "transferPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "pay_type", property = "payType", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP)
    })
    List<Order> selectFinishByTimeLimit(@Param("time")Date time, @Param("aLong")Long aLong);

    @Select({
            "select",
            " id, m_id, order_num,store_id,order_type, express_name, express_number, name, phone, address, total_price, ",
            " tip_price,transfer_price, status,pay_type, create_time, modify_time ",
            " from t_order ",
            " where store_id = #{id,jdbcType=BIGINT}  and status!='9' order by create_time desc"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "m_id", property = "mId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_num", property = "orderNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "store_id", property = "storeId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_type", property = "orderType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_name", property = "expressName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_number", property = "expressNumber", jdbcType = JdbcType.VARCHAR),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "total_price", property = "totalPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "tip_price", property = "tipPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "transfer_price", property = "transferPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "pay_type", property = "payType", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP)
    })
    List<Order> selectByStoreId( @Param("id")Long id);

    @Select({
            "select",
            " id, m_id, order_num,store_id,order_type, express_name, express_number, name, phone, address, total_price, ",
            " tip_price,transfer_price, status,pay_type, create_time, modify_time ",
            " from t_order ",
            " where m_id = #{id,jdbcType=BIGINT} and status='3'"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "m_id", property = "mId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_num", property = "orderNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "store_id", property = "storeId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_type", property = "orderType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_name", property = "expressName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_number", property = "expressNumber", jdbcType = JdbcType.VARCHAR),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "total_price", property = "totalPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "tip_price", property = "tipPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "transfer_price", property = "transferPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "pay_type", property = "payType", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP)
    })
    List<Order> selectByMidAndFinish(Long id);

    @Select({
            "select",
            " id, m_id, order_num,store_id,order_type, express_name, express_number, name, phone, address, total_price, ",
            " tip_price,transfer_price, status,pay_type, create_time, modify_time ",
            " from t_order ",
            " where order_num = #{orderNum,jdbcType=VARCHAR} "
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "m_id", property = "mId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_num", property = "orderNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "store_id", property = "storeId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_type", property = "orderType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_name", property = "expressName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_number", property = "expressNumber", jdbcType = JdbcType.VARCHAR),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "total_price", property = "totalPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "tip_price", property = "tipPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "transfer_price", property = "transferPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "pay_type", property = "payType", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP)
    })
    Order selectByOrderNum(@Param("orderNum") String orderNum);


    @Update({
            "update t_order",
            " set status = '9',",
            " modify_time =now() ",
            " where order_num = #{orderNum,jdbcType=VARCHAR}"
    })
    void deleteByPrimaryKeyLogic(@Param("orderNum") String orderNum);




    @Select({
            "select",
            " id, m_id, order_num,store_id,order_type, express_name, express_number, name, phone, address, total_price,",
            " tip_price,transfer_price, status,pay_type, create_time, modify_time ",
            " from t_order ",
            " where (pay_type=4 or pay_type=5) and status = 0 and create_time <= date_add(now(), interval - 5 MINUTE)"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "m_id", property = "mId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_num", property = "orderNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "store_id", property = "storeId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_type", property = "orderType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_name", property = "expressName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_number", property = "expressNumber", jdbcType = JdbcType.VARCHAR),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "total_price", property = "totalPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "tip_price", property = "tipPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "transfer_price", property = "transferPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "pay_type", property = "payType", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP)
    })
    List<Order> selectByStatus();

    @Select({
            "select",
            " id, m_id, order_num,store_id,order_type, express_name, express_number, name, phone, address, total_price, ",
            " tip_price,transfer_price, status,pay_type, create_time, modify_time ",
            " from t_order ",
            " where pay_type=4  and status = 0 and create_time <= date_add(now(), interval - 8 SECOND)"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "m_id", property = "mId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_num", property = "orderNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "store_id", property = "storeId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_type", property = "orderType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_name", property = "expressName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_number", property = "expressNumber", jdbcType = JdbcType.VARCHAR),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "total_price", property = "totalPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "tip_price", property = "tipPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "transfer_price", property = "transferPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "pay_type", property = "payType", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP)
    })
    List<Order> selectByPaytypeAndStatus();

    @Select({
            "select sum(total_price)+SUM(tip_price) from t_order where to_days(create_time)= to_days(now()) and status!=9"
    })
    BigDecimal countTodayNum();


    @Select({
            "select sum(total_price)+SUM(tip_price) from t_order where TO_DAYS( create_time) +1=TO_DAYS( NOW( ) ) and status!=9"
    })
    BigDecimal countYesterdayNum();

    @Select({
            "select sum(total_price)+SUM(tip_price) from t_order where status!=9"
    })
    BigDecimal countTotalNum();

    @SelectProvider(type = OrderSqlProvider.class, method = "selectAllOrders")
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "m_id", property = "mId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_num", property = "orderNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "store_id", property = "storeId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_type", property = "orderType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_name", property = "expressName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "express_number", property = "expressNumber", jdbcType = JdbcType.VARCHAR),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "total_price", property = "totalPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "tip_price", property = "tipPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "transfer_price", property = "transferPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "pay_type", property = "payType", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP)
    })
    Page<Order> selectAllOrders(WebOrderController.OrderColumns orderColumns);

    @Select({
            "select count(0) from t_order where m_id= #{id,jdbcType=BIGINT} and status!=9"
    })
    Integer countOrderByMidAndNotCancel(Long id);
}